package cn.usts.edu.lesson01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestPanel {

    public static void main(String[] args) {


        Frame frame = new Frame();
        // 设置标题
        frame.setTitle("firstFrame");
        // 设置布局
        frame.setLayout(null);
        // 设置位置
        frame.setBounds(100,100,800,800);
        // 设置背景色
        frame.setBackground(Color.orange);
        // 设置可见性
        frame.setVisible(true);
        
        Panel panel01 = new Panel();
        // 设置布局
        panel01.setBounds(50,50,200,200);
        panel01.setBackground(Color.PINK);
        // 把组件添加到frame中
        frame.add(panel01);
        panel01.setVisible(true);


        Panel panel02 = new Panel();
        // 设置布局
        panel02.setBounds(210,280,200,200);
        panel02.setBackground(Color.BLUE);
        panel02.setVisible(true);

        // 把组件添加到frame中
        frame.add(panel01);
        frame.add(panel02);

        // 监听事件,监听窗口关闭实践
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
}
